package com.xuxin.pda.presenter;

import com.xuxin.pda.bean.BaseBean;
import com.xuxin.pda.bean.CommitBean;
import com.xuxin.pda.bean.DepartmentBean;
import com.xuxin.pda.bean.TrashTypeBean;
import com.xuxin.pda.contract.TrashCollectContract;
import com.xuxin.pda.model.TrashCollectModel;

/**
 * Created by xu_xin
 * Created on 2020/12/24 0024
 */
public class TrashCollectPresenter implements TrashCollectContract.Presenter {
    private final TrashCollectModel model;
    private final TrashCollectContract.View view;

    public TrashCollectPresenter(TrashCollectContract.View view) {
        this.view = view;
        model = new TrashCollectModel();
    }

    @Override
    public void getDepartment(String departmentId) {
        if (null != model) {
            model.getDepartment(this, departmentId);
        }
    }

    @Override
    public void getTrashType() {
        if (null != model) {
            model.getTrashType(this);
        }
    }

    @Override
    public void commit(String userId, String weight, String departmentId, String categoryName,String ENum) {
        if (null != model) {
            model.commit(this, userId, weight, departmentId, categoryName,ENum);
        }
    }

    @Override
    public void onSuccess(DepartmentBean dptBean) {
        if (null != view) {
            view.onSuccess(dptBean);
        }
    }

    @Override
    public void onSuccess(TrashTypeBean wasteTypeBean) {
        if (null != view) {
            view.onSuccess(wasteTypeBean);
        }
    }

    @Override
    public void onSuccess(CommitBean commitBean) {
        if (null != view) {
            view.onSuccess(commitBean);
        }
    }

    /**
     * 以下内容复用
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}